<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>

<script language="javascript" src="<%= request.getContextPath() %>/cs/js/date.js" type="text/javascript">
</script>

<script language="javascript">


function isValAllDigits(argvalue) {
  argvalue = argvalue.toString();
  var validChars = "0123456789";
  var startFrom = 0;
  for (var n = startFrom; n < argvalue.length; n++) {
    if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
  }
  return true;
}

function isAllZeros(argvalue) {
  argvalue = argvalue.toString();
  var validChars = "0";
  var startFrom = 0;
  for (var n = startFrom; n < argvalue.length; n++) {
    if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
  }
  return true;
}

function onClickSearch(theForm) {
  value=theForm.maxReturn.value;
  if (value.length < 0) {
    alert('<bean:message bundle="appCommonRes" key="bp.error.mycs.search.maxReturns"/>');
    return false;
  }
  if (!isValAllDigits(value) || isAllZeros(value)) {
    alert('<bean:message bundle="appCommonRes" key="bp.error.mycs.search.maxReturns"/>');
    return false;
  }
  return true;
}
</script>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
<tr>
<td valign="top" width="100%">

<html:form action="/myCSSearch.do">
  <input type="hidden" name="doSearch" value="true">
  <div class="app_pageTitle"><bean:message bundle="appCommonRes" key="bp.mycs.pagetitle" /></div> 
 
  <div class="app_pageSubtitle">
    <span class="left">&nbsp;</span>
    <span class="right">&nbsp;</span>
  </div> 
  <!--end page title area here-->
  
	<div class="blockWrap">
  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Search criterias">
    <tr>
      <td class="label" width="20%" nowrap><bean:message bundle="appCommonRes" key="bp.mycs.search.name"/>:</td>
	  <td class="labelField" width="80%">
	    <html:text property="csNameCriteria" size="31" maxlength="80" />
	  </td>
    </tr>
    <tr>
      <td class="label" width="20%" nowrap><bean:message bundle="appCommonRes" key="bp.mycs.status"/>:</td>
	  <td class="labelField" width="80%">
  	    <html:radio property="statusCriteria" value="0" />
 	    <bean:message bundle="appCommonRes" key="bp.mycs.status.all" />
	    <html:radio property="statusCriteria" value="1" />
	    <bean:message bundle="appCommonRes" key="cs.status.active" />
	    <html:radio property="statusCriteria" value="2" />
	    <bean:message bundle="appCommonRes" key="cs.status.completed" />	    
	  </td>
    </tr>
    <tr>
      <td class="label" width="20%" nowrap><bean:message bundle="appCommonRes" key="bp.mycs.max.return"/>:</td>
	  <td class="labelField" width="80%">
	    <html:text property="maxReturn" size="5" maxlength="80" />
	  </td>
    </tr>
    <tr>
      <td class="label" width="20%"><bean:message bundle="appCommonRes" key="bp.mycs.created.between"/>:</td>
      <td class="labelField" width = "70%" nowrap>
        <bvhtml:date property="creationDateStart"/>
        <a href="JavaScript:datePopup('<html:rewrite   page="/cs/calendar.do"/>',
                            'myCSSearchForm','creationDateStart')">
          <img src="<%= request.getContextPath() %>/ca/images/icons/calendar.gif" 
      		     width="23" height="22" border="0" align="absmiddle" alt="<bean:message key="cs.image.alt.calendar"/>" title="<bean:message key="cs.image.alt.calendar"/>"/></a>
        <html:hidden property="creationDateStart.hour" value="0"/>
        <html:hidden property="creationDateStart.minute" value="0"/>
        <html:hidden property="creationDateStart.ind" value="0"/>

        <br>
        <bean:message bundle="appCommonRes" key="bp.processInstance.search.and" />
        <br>
        <bvhtml:date property="creationDateEnd"/>
      	<a href="JavaScript:datePopup('<html:rewrite   page="/cs/calendar.do"/>',
      	                   'myCSSearchForm','creationDateEnd')">
      	  <img src="<%= request.getContextPath() %>/ca/images/icons/calendar.gif" 
      		     width="23" height="22" border="0" align="absmiddle" alt="<bean:message key="cs.image.alt.calendar"/>" title="<bean:message key="cs.image.alt.calendar"/>"/></a>
        <html:hidden property="creationDateEnd.hour" value="23"/>
        <html:hidden property="creationDateEnd.minute" value="59"/>
        <html:hidden property="creationDateEnd.ind" value="59"/>
	  </td>
    </tr>
    <tr>
      <td class="label" width="20%" nowrap><bean:message bundle="appCommonRes" key="bp.mycs.order.by"/>:</td>
	  <td class="labelField" width="80%">
	    <html:select property="sortBy">
	      <html:option value="creationTime" key="bp.mycs.creationdate" bundle="appCommonRes" />
   	      <html:option value="name" key="bp.mycs.search.name" bundle="appCommonRes" />
	    </html:select>
	    <html:select property="ascending">
	      <html:option value="true" key="bp.mycs.order.ascending" bundle="appCommonRes" />
	      <html:option value="false" key="bp.mycs.order.descending" bundle="appCommonRes" />
	    </html:select>
	  </td>
    </tr>
  </table>
  <div class="pageButtonWrap" align="right">
    <html:reset property="resetBtn" styleClass="pageButton">
      <bean:message bundle="appCommonRes" key="button.reset" />
    </html:reset>
    <html:submit property="submitBtn" styleClass="pageButton" onclick="return onClickSearch(this.form)">
      <bean:message bundle="appCommonRes" key="bp.mycs.search" />
    </html:submit>
  </div> 

</div>  
</html:form>

<%-- End of seach criteria section. --%>  

<!-- Start List here -->
<logic:equal name="myCSSearchForm" property="doSearch" value="true">
  <div class="app_pageSubtitle">
    <span class="left"><bean:message bundle="appCommonRes" key="bp.mycs.search.result.title" /></span>
    <span class="right">&nbsp;</span>
  </div> 
	
  <div class="blockWrap">
	<table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="My Collaboration Space List" width="100%">
    <tr class="listHeader"> 
      <th align="left"><bean:message bundle="appCommonRes" key="bp.mycs.search.name" /></th>
      <th align="left"><bean:message bundle="appCommonRes" key="cs.status" /></th>
      <th align="left"><bean:message bundle="appCommonRes" key="bp.mycs.creationdate" /></th>
    </tr>
  <logic:empty name="MyCSSearchAction_result">
    <tr class="listOdd"> 
        <td align="center" colspan="4"><bean:message bundle="appCommonRes" key="bp.mycs.search.result.no" /></td>
    </tr>
  </logic:empty>
  <logic:notEmpty name="MyCSSearchAction_result">
    <logic:iterate id="oneItem" name="MyCSSearchAction_result" indexId="index">
      <tr class="<%=index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>">
        <td>
          <html:link page="/cs/micrositeHome.do" paramId="micrositeId" 
                 paramName="oneItem" paramProperty="id">
            <bean:write name="oneItem" property = "name"  />
          </html:link>
        </td>
        <td>
          <logic:equal name="oneItem" property="closed" value="true">
            <bean:message bundle="appCommonRes" key="cs.status.completed" />
          </logic:equal>

          <logic:notEqual name="oneItem" property="closed" value="true">
            <bean:message bundle="appCommonRes" key="cs.status.active" />
          </logic:notEqual>
        </td>
        <td>
          <bean:write bundle="appCommonRes" name="oneItem" property ="creationTime" formatKey="format.datetime.short"/>
        </td>
      </tr>
    </logic:iterate>
    </logic:notEmpty>
	</table>
</logic:equal>   
</div>
</td>
</tr>
</table>



